package ar.com.gals.configuration;

import java.util.Enumeration;
import java.util.Properties;
import java.util.ResourceBundle;


/**
 * @author gmancini
 * @version 1.0
 * @created 21-oct-2013 01:49:35 p.m.
 */
public class Configuration {

	private static Configuration instance = new Configuration();
	private final String PROPERTY_NAME = "configuration";
	private Properties properties = null;
	
	
	/**
     * Carga el archivo de properties.
     */  
    private Configuration() {

    	properties = convertResourceBundleToProperties(ResourceBundle.getBundle(PROPERTY_NAME));
    }
    
    /** 
    * Convert ResourceBundle into a Properties object. 
    * 
    * @param resource a resource bundle to convert. 
    * @return Properties a properties version of the resource bundle. 
    */
    private static Properties convertResourceBundleToProperties(ResourceBundle resource) { 

    	Properties properties = new Properties(); 
   	 
    	Enumeration<String> keys = resource.getKeys(); 
    	while (keys.hasMoreElements()) { 
	    	String key = keys.nextElement(); 
	    	properties.put(key, resource.getString(key)); 
    	} 
    	 
    	return properties; 
    } 
    
	public static Configuration getInstance() {
		return instance;
	}
	
	public String getGalsFolder(){
		return properties.getProperty("folder.gals");
	}
	
	public String getTempFolder(){
		return properties.getProperty("folder.temp");
	}
	
	public String getBigImageFolder(){
		return properties.getProperty("folder.bigImage");
	}
	
	public String getSmallImageFolder(){
		return properties.getProperty("folder.smallImage");
	}
	
	public String getListaPreciosFolder(){
		return properties.getProperty("folder.listaPrecios");
	}

}
